package com.example.ploy4j.mapper;

import com.example.ploy4j.dto.DeploymentJobDto;
import com.example.ploy4j.entity.DeploymentJob;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

import java.util.List;

@Mapper(componentModel = "spring")
public interface DeploymentJobMapper {

    DeploymentJobMapper INSTANCE = Mappers.getMapper(DeploymentJobMapper.class);

    @Mappings({
        @Mapping(source = "gitRepositoryConfig.projectName", target = "gitRepositoryProjectName"),
        @Mapping(source = "serverConfig.name", target = "serverConfigName")
    })
    DeploymentJobDto toDto(DeploymentJob deploymentJob);

    // If you need to map DTO back to Entity, define it here. For now, we primarily need Entity -> DTO.
    // @Mapping(target = "gitRepositoryConfig", ignore = true) // Example: ignore complex objects or handle them specifically
    // @Mapping(target = "serverConfig", ignore = true)
    // DeploymentJob toEntity(DeploymentJobDto deploymentJobDto);

    List<DeploymentJobDto> toDtoList(List<DeploymentJob> deploymentJobs);
} 